$(function () {
    $("#jqGrid").jqGrid({
        url: '../salarybasicinfo/list',
        datatype: "json",
        colModel: [			
			{ label: 'id', name: 'id', index: 'id', key: true ,hidden:true},
			{ label: '', name: 'settlementid', index: 'settlementid' ,hidden:true},
			{ label: '状态', name: 'status', index: 'status'}, 			
			{ label: '员工姓名', name: 'empname', index: 'empname'}, 			
			{ label: '员工编号', name: 'empid', index: 'empid'}, 			
			{ label: '身份证号', name: 'cardno', index: 'cardno'}, 			
			{ label: '年', name: 'year', index: 'year'}, 			
			{ label: '月', name: 'month', index: 'month'}, 			
			{ label: '批次', name: 'batch', index: 'batch'},
			{ label: '应发工资-应发工资', name: 'yfgzSalary', index: 'yfgz_salary'}, 			
			{ label: '应发工资-加班费', name: 'yfgzOuttimepay', index: 'yfgz_outtimepay'}, 			
			{ label: '应发工资-社保补助', name: 'yfgzShebaobz', index: 'yfgz_shebaobz'}, 			
			{ label: '应发工资-绩效工资', name: 'yfgzJixiaosalary', index: 'yfgz_jixiaosalary'}, 			
			{ label: '应发工资-工龄工资', name: 'yfgzGonglsalary', index: 'yfgz_gonglsalary'}, 			
			{ label: '应发工资-其他补助', name: 'yfgzOtherbz', index: 'yfgz_otherbz'}, 			
			{ label: '应发工资-交通核报', name: 'yfgzJiaothb', index: 'yfgz_jiaothb'}, 			
			{ label: '应发工资-通讯核报', name: 'yfgzTongxhb', index: 'yfgz_tongxhb'}, 			
			{ label: '应发工资-其他核报', name: 'yfgzOtherhb', index: 'yfgz_otherhb'}, 			
			{ label: '应发工资-午餐补助', name: 'yfgzWucanbz', index: 'yfgz_wucanbz'}, 			
			{ label: '社保个人-工伤', name: 'sbgrGongs', index: 'sbgr_gongs'}, 			
			{ label: '社保个人-养老', name: 'sbgrYangl', index: 'sbgr_yangl'}, 			
			{ label: '社保个人-失业', name: 'sbgrShiy', index: 'sbgr_shiy'}, 			
			{ label: '社保个人-医疗', name: 'sbgrYil', index: 'sbgr_yil'}, 			
			{ label: '社保个人-公积金(正常部分)', name: 'sbgrGongjjZc', index: 'sbgr_gongjj_zc'}, 			
			{ label: '社保个人-公积金补退(管理员工特有)', name: 'sbgrGongjjBt', index: 'sbgr_gongjj_bt'}, 			
			{ label: '社保个人-大病', name: 'sbgrDab', index: 'sbgr_dab'}, 			
			{ label: '社保补差-工商', name: 'sbbcGongs', index: 'sbbc_gongs'}, 			
			{ label: '社保补差-养老', name: 'sbbcYangl', index: 'sbbc_yangl'}, 			
			{ label: '社保补差-失业', name: 'sbbcShiy', index: 'sbbc_shiy'}, 			
			{ label: '社保补差-医疗', name: 'sbbcYil', index: 'sbbc_yil'}, 			
			{ label: '实发工资-手续费', name: 'sfgzShouxf', index: 'sfgz_shouxf'}, 			
			{ label: '实发工资-扣税', name: 'sfgzTax', index: 'sfgz_tax'}, 			
			{ label: '实发工资-实发工资', name: 'sfgzSalary', index: 'sfgz_salary'}, 			
			{ label: '实发工资-经济补偿金', name: 'sfgzJinjbcj', index: 'sfgz_jinjbcj'}, 			
			{ label: '实发工资-情况说明', name: 'sfgzRemark', index: 'sfgz_remark'}, 			
			{ label: '其他扣款项目-劳务员工-个人往来', name: 'qtkkLwygGerenwl', index: 'qtkk_lwyg_gerenwl'}, 			
			{ label: '其他扣款项目-劳务员工-派遣考核款', name: 'qtkkLwygPaiqkh', index: 'qtkk_lwyg_paiqkh'}, 			
			{ label: '其他扣款项目-劳务员工-项目奖罚金', name: 'qtkkLwygProjectfk', index: 'qtkk_lwyg_projectfk'}, 			
			{ label: '其他扣款项目-劳务员工-体检费', name: 'qtkkLwygTijian', index: 'qtkk_lwyg_tijian'}, 			
			{ label: '其他扣款项目-劳务员工-水电费', name: 'qtkkLwygShuidf', index: 'qtkk_lwyg_shuidf'}, 			
			{ label: '其他扣款项目-劳务员工-工会', name: 'qtkkLwygGonghui', index: 'qtkk_lwyg_gonghui'}, 			
			{ label: '其他扣款项目-劳务员工-工会医疗互助', name: 'qtkkLwygGonghyilhz', index: 'qtkk_lwyg_gonghyilhz'}, 			
			{ label: '其他扣款项目-劳务员工-伙食费', name: 'qtkkLwygFood', index: 'qtkk_lwyg_food'}, 			
			{ label: '其他扣款项目-劳务员工-劳保用品', name: 'qtkkLwygLaobaoyp', index: 'qtkk_lwyg_laobaoyp'}, 			
			{ label: '其他扣款项目-劳务员工-福利费', name: 'qtkkLwygFulif', index: 'qtkk_lwyg_fulif'}, 			
			{ label: '其他扣款项目-劳务员工-补个税', name: 'qtkkLwygBupersontax', index: 'qtkk_lwyg_bupersontax'}, 			
			{ label: '其他扣款项目-劳务员工-管理费', name: 'qtkkLwygManagementpay', index: 'qtkk_lwyg_managementpay'}, 			
			{ label: '其他扣款项目-管理员工-工作服', name: 'qtkkGlygWorkclothes', index: 'qtkk_glyg_workclothes'}, 			
			{ label: '其他扣款项目-管理员工-伙食费', name: 'qtkkGlygFood', index: 'qtkk_glyg_food'}, 			
			{ label: '其他扣款项目-管理员工-个人往来', name: 'qtkkGlygGerenwl', index: 'qtkk_glyg_gerenwl'}, 			
			{ label: '其他扣款项目-管理员工-奖罚款', name: 'qtkkGlygJiangfk', index: 'qtkk_glyg_jiangfk'}, 			
			{ label: '其他扣款项目-管理员工-体检费', name: 'qtkkGlygTijian', index: 'qtkk_glyg_tijian'}, 			
			{ label: '其他扣款项目-管理员工-工会', name: 'qtkkGlygGonghui', index: 'qtkk_glyg_gonghui'}, 			
			{ label: '其他-预留1', name: 'otherYuliu1', index: 'other_yuliu1'}, 			
			{ label: '其他-预留2', name: 'otherYuliu2', index: 'other_yuliu2'}, 			
			{ label: '其他-预留3', name: 'otherYuliu3', index: 'other_yuliu3'}, 			
			{ label: '其他-预留4', name: 'otherYuliu4', index: 'other_yuliu4'}, 			
			{ label: '其他-预留5', name: 'otherYuliu5', index: 'other_yuliu5'}, 			
			{ label: '基础信息(税额)', name: 'basicTax', index: 'basic_tax'}, 			
			{ label: '一审日期', name: 'basicFirstinstanceDate', index: 'basic_firstinstance_date'}, 			
			{ label: '一审人', name: 'basicFirstinstancePerson', index: 'basic_firstinstance_person'}, 			
			{ label: '二审日期', name: 'basicSecinstanceDate', index: 'basic_secinstance_date'}, 			
			{ label: '二审人', name: 'basicSecinstancePerson', index: 'basic_secinstance_person'}, 			
			{ label: '三审日期', name: 'basicThrinstanceDate', index: 'basic_thrinstance_date'}, 			
			{ label: '三审人', name: 'basicThrinstancePerson', index: 'basic_thrinstance_person'}, 			
			{ label: '状态', name: 'basicStatus', index: 'basic_status'}			
        ],
		viewrecords: true,
        height: 385,
        rowNum: 10,
		rowList : [10,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        //字段太多自动加载横轴滚动条
        shrinkToFit:false,
        autoScroll: false,
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	//$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
        }
    });
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		showList: true,
		title: null,
		salaryBasicinfo: {}
	},
	methods: {
		query: function () {
			vm.reload();
		},
		add: function(){
			vm.showList = false;
			vm.title = "新增";
			vm.salaryBasicinfo = {};
		},
		update: function (event) {
			var id = getSelectedRow();
			if(id == null){
				return ;
			}
			vm.showList = false;
            vm.title = "修改";
            
            vm.getInfo(id)
		},
		saveOrUpdate: function (event) {
			var url = vm.salaryBasicinfo.id == null ? "../salarybasicinfo/save" : "../salarybasicinfo/update";
			$.ajax({
				type: "POST",
			    url: url,
			    contentType: "application/json",
			    data: JSON.stringify(vm.salaryBasicinfo),
			    success: function(r){
			    	if(r.code === 0){
						alert('操作成功', function(index){
							vm.reload();
						});
					}else{
						alert(r.msg);
					}
				}
			});
		},
		del: function (event) {
			var ids = getSelectedRows();
			if(ids == null){
				return ;
			}
			
			confirm('确定要删除选中的记录？', function(){
				$.ajax({
					type: "POST",
				    url: "../salarybasicinfo/delete",
				    contentType: "application/json",
				    data: JSON.stringify(ids),
				    success: function(r){
						if(r.code == 0){
							alert('操作成功', function(index){
								$("#jqGrid").trigger("reloadGrid");
							});
						}else{
							alert(r.msg);
						}
					}
				});
			});
		},
        Trial: function(type){
            var ids = getSelectedRows();
            if (ids == null) {
                return;
            }

            var params = new Object();
            params.ids = ids;
            params.type = type;
            $.ajax({
                type: "POST",
                url: "../salarybasicinfo/updateTrialStatus",
                contentType: "application/json",
                data: JSON.stringify(params),
                success: function (r) {
                    if (r.code == 0) {
                        alert('操作成功', function (index) {
                            $("#jqGrid").trigger("reloadGrid");
                        });
                    } else {
                        alert(r.msg);
                    }
                }
            });
        },
		getInfo: function(id){
			$.get("../salarybasicinfo/info/"+id, function(r){
                vm.salaryBasicinfo = r.salaryBasicinfo;
            });
		},
		reload: function (event) {
			vm.showList = true;
			var page = $("#jqGrid").jqGrid('getGridParam','page');
			$("#jqGrid").jqGrid('setGridParam',{ 
                page:page
            }).trigger("reloadGrid");
		}
	}
});